package org.dzl.springboot001.controller;

import org.dzl.springboot001.config.JSONResult;
import org.dzl.springboot001.dao.UserMapper;
import org.dzl.springboot001.entity.User;
import org.dzl.springboot001.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author 光的代言人
 */
@Controller
@RequestMapping("admin/user")
public class UserController {
    @Autowired
    private UserService userService;
    @GetMapping("all")
    @ResponseBody
    public JSONResult getUserList(Model model){
        List<User> userList = userService.getUserList();
        model.addAttribute("userList",userList);
        return new JSONResult("success",userList);
//        return "user/all";
    }
}
